package com.kq.tallybookl.database;

import android.content.Context;

import net.sqlcipher.database.SQLiteDatabase;
import net.sqlcipher.database.SQLiteOpenHelper;

/**
 * 真正的事件信息数据库操作辅助类
 * Created by Kq on 2016/4/28.
 */
public class TrueDBHelper extends SQLiteOpenHelper{

    private static final int DB_VERSION = 1;
    private static final String DB_NAME = "tally_book_l1.db";

    static final String TABLE_NAME = "tally_book";
    static final String ID_COL = "id";
    static final String TITLE_COL = "title";
    static final String TIMESTAMP_COL = "timestamp";
    static final String DETAILS_COL = "details";


    public TrueDBHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL("CREATE TABLE " + TABLE_NAME + " ("
                + ID_COL + " INTEGER PRIMARY KEY, " + TITLE_COL + " TEXT, "
                + TIMESTAMP_COL + " INTEGER, " + DETAILS_COL + " TEXT);");
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
        sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
        onCreate(sqLiteDatabase);
    }
}
